﻿package component.validate.util;

import java.io.IOException;
import java.io.InputStream;

public class StringUtil {
	public static boolean isNull(String value) {
		if ("".equals(value) || null == value || value.equalsIgnoreCase("null") || "undefined".equals(value)) {
			return true;
		}
		return false;
	}
	
	//把字节流转化成String
    public static String streamToString(InputStream stream) {
		byte[] b = new byte[1024];
		StringBuffer sb = new StringBuffer();
		int pos = 0;
		try {
			while ((pos = stream.read(b)) > 0) {
				sb.append(new String(b, 0, pos));
			}
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			try {
				stream.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return sb.toString().trim();
	}
    
    //去掉换行符号，java->js
    public static String removeLineBreaks(String str){
    	return str.replaceAll("\r\n", " ");
    }

}
